<?php
class Student
{
private $surname;
private $first_name;
private $emails;
private $grades;
private $status;
public function __construct($surname, $first_name,$status)
{
$this->surname = $surname;
$this->first_name = $first_name;
$this->status = $status;
}
public function add_email($which, $address)
{
$this->emails[$which] = $address;
}
public function add_grade($grade)
{
$this->grades[] = $grade;
}
public function average()
{
$total = 0;
foreach ($this->grades as $value)
$total += $value;
return $total / count($this->grades);
}
public function toString(): string
{
    $result = $this->first_name . ' ' . $this->surname . " (Status: " . $this->status . ")\n";
    $result .= '(' . $this->average() . ")\n";
    foreach ($this->emails as $which => $what)
        $result .= $which . ': ' . $what . "\n";
    $result .= "\n";
    return '<pre>' . $result . '</pre>';
}
}
